<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>1111</title>
</head>
<body>
<div>
    <canvas id="canvas" width="1000" height="800"></canvas>
    <input type="button" value="重写" onclick="rewrite()"/>
    <input type="button" value="确定" onclick="submit()"/>
</div>
<script src="./dyCanvas.min.js"></script>
<script>
    let dyCanvas = new DyCanvas({
        el: 'canvas',
        color: '#000',
        bgColor: '#555',
        lineWidth: 8,
        brush: true,
    });
    dyCanvas.initCvs();


    /**
     * 重写签名
     */
    function rewrite() {
        dyCanvas.initCvs();
    }

    /**
     * 确定签名
     */
    function submit() {
        var canvas = document.getElementById("canvas");
        var ctx = canvas.getContext("2d");

        // 绘制您的画布内容
        // ...
        // 获取画布内容的base64编码
        var dataURL = canvas.toDataURL();
        console.log(dataURL)
    }
</script>
</body>
</html>
